<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
	Advanced Users Search
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>
<div id="content" class="box">
	<h1>Advanced Users Search</h1>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
	<fieldset>
		<legend>Search</legend>
			<form action="<?echo url('user/advancedsearch'); ?>" method="get">
				<div class="row">
					<div class="row-left">
						<label class="search-label">State:</label><input type="text" name="state" value="<?php echo isset($state) ? $state : ''; ?>"/>
					</div>
					<div class="row-right">
						<label class="search-label">Gender:</label>
						<input type="radio" name="gender" value="M" <?php echo ('M'==$gender) ? 'checked="checked"' : '';?>/><label>Male</label>
						<input type="radio" name="gender" value="F" <?php echo ('F'==$gender) ? 'checked="checked"' : '';?>/><label>Female</label>
					</div>
				</div>
				<div class="clear"></div>
				<div class="row">
					<div class="row-left">
						<label class="search-label">Site:</label>
						<?php
							 echo Util::buildDropDownList(
							 	array('id'=>'site', 'name'=>'site'),
							 	$sites,
							 	isset($site) ? $site: false,
							 	array('k'=>'', 'l'=>'--All--')
							 );
						?>
					</div>
					<div class="row-right">
						<label class="search-label">Subscribed:</label>
						<input type="radio" name="subscribe" value="0" <?php echo (!is_null($subscribe) && 0==$subscribe) ? 'checked="checked"' : '';?>/><label>Yes</label>
						<input type="radio" name="subscribe" value="1" <?php echo (1==$subscribe) ? 'checked="checked"' : '';?>/><label>No</label>
					</div>
				</div>
				<div class="clear"></div>
				<div class="row">
					<div class="row-left">
						<label>Credit</label>  <label>From:</label>
							<input type="text" name="credit_from" class="input-text-small" value="<?php echo !is_null($credit_from) ? $credit_from : '';?>" />
						<label>To:</label>
							<input type="text" name="credit_to" class="input-text-small" value="<?php echo !is_null($credit_to) ? $credit_to : '';?>"/>
					</div>
					<div class="row-right">
						<label>Won</label>  <label>From:</label>
							<input type="text" name="won_from" class="input-text-small" value="<?php echo !is_null($won_from) ? $won_from : '';?>"/>
						<label>To:</label>
							<input type="text" name="won_to" class="input-text-small" value="<?php echo !is_null($won_to) ? $won_to : '';?>"/>
					</div>
				</div>
				<div class="clear"></div>
				<div class="row">
					
				</div>
				<div class="clear"></div>
				<div class="row">
					<div class="row-left">
						<label>Balance</label>  <label>From:</label>
							<input type="text" name="balance_from" class="input-text-small" value="<?php echo !is_null($balance_from) ? $balance_from : '';?>"/>
						<label>To:</label>
							<input type="text" name="balance_to" class="input-text-small" value="<?php echo !is_null($balance_to) ? $balance_to : '';?>"/>
					</div>
				</div>
				<div class="clear"></div>
				<div class="row">
					
				</div>
				<div class="clear"></div>
				<div class="row">
					<div class="row-left">
						<label>Created</label>  <label>From:</label>
							<input type="text" name="created_from" class="input-date" value="<?php echo !is_null($created_from) ? $created_from : '';?>"/>
						<label>To:</label>
							<input type="text" name="created_to" class="input-date" value="<?php echo !is_null($created_to) ? $created_to : '';?>"/>
					</div>
					<div class="row-right">
						<label>Last Visited</label>  <label>From:</label>
							<input type="text" name="lvisit_from" class="input-date" value="<?php echo !is_null($lvisit_from) ? $lvisit_from : '';?>"/>
						<label>To:</label>
							<input type="text" name="lvisit_to" class="input-date" value="<?php echo !is_null($lvisit_to) ? $lvisit_to : '';?>"/>
					</div>
				</div>
				<div class="clear"></div>
				<div class="row">
					<input type="submit" value="Search" /><input type="reset" value="Reset"/>
				</div>
			</form>
	</fieldset>
	<table class="full-size">
		<tbody>
			<tr>
				<th>ID</th>
				<th>Domain</th>
				<th>Name</th>
				<th>State</th>
				<th>Won</th>
				<th>Balance</th>
				<th>Last Visit</th>
			</tr>
			<?php
				$bg = false;
				if(!empty($users)){
					foreach ($users as $user)
					{
			?>
			<tr <?php if ($bg) echo 'class="bg"';?>>
				<td><?php echo $user['id'];?></td>
				<td><?php echo $user['domain'];?></td>
				<td><?php echo $user['fistname'] . $user['lastname'];?></td>
				<td><?php echo $user['state']; ?></td>
				<td><?php echo $user['won']; ?></td>
				<td><?php echo $user['balance']; ?></td>
				<td><?php echo date('m/d/Y H:i:s', $user['last_visit']); ?></td>
			</tr>
			<?php
					$bg = !$bg;
					}
				}
			?>
		</tbody>
	</table>
	<div class="pagination">
		<?php echo $pagination; ?>
	</div>
</div>
<script type="text/javascript">
	$(function(){
		$('.input-date').datepicker();
	});
</script>
<?php $this->_endblock(); ?>